package com.ruoyi.recycle.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.ruoyi.recycle.domain.RecycleCommodity;
import com.ruoyi.recycle.vo.RecycleCategoryVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 回收商品Mapper接口
 *
 * @author ruoyi
 * @date 2022-05-22
 */
public interface RecycleCommodityMapper extends BaseMapper<RecycleCommodity> {
    /**
     * 查询回收商品
     *
     * @param id 回收商品主键
     * @return 回收商品
     */
    public RecycleCommodity selectRecycleCommodityById(Long id);

    /**
     * 查询回收商品列表
     *
     * @param recycleCommodity 回收商品
     * @return 回收商品集合
     */
    public List<RecycleCommodity> selectRecycleCommodityList(RecycleCommodity recycleCommodity);

    /**
     * 新增回收商品
     *
     * @param recycleCommodity 回收商品
     * @return 结果
     */
    public int insertRecycleCommodity(RecycleCommodity recycleCommodity);

    /**
     * 修改回收商品
     *
     * @param recycleCommodity 回收商品
     * @return 结果
     */
    public int updateRecycleCommodity(RecycleCommodity recycleCommodity);

    /**
     * 删除回收商品
     *
     * @param id 回收商品主键
     * @return 结果
     */
    public int deleteRecycleCommodityById(Long id);

    /**
     * 批量删除回收商品
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteRecycleCommodityByIds(Long[] ids);

    @Select("select recycle_name as category, sum(practical_weight) as weight from recycle_commodity ${ew.customSqlSegment}")
    List<RecycleCategoryVO.CategoryVO> sumWeightByType(@Param(Constants.WRAPPER) LambdaQueryWrapper<RecycleCommodity> queryWrapper);
}
